﻿using Ducu.SRV.ServiceInteface;
using Ducu.SRV.ViewModel.Shared;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Ducu.UI.Responsible.Controllers
{
    [ChildActionOnly]
    public class SharedController : BaseController
    {
        #region Constructor

        private ISharedService _sharedService;
        private IPlanService _planService;
        private ITaskService _taskService;
        public SharedController(ISharedService sharedService,
            IPlanService planService,
            ITaskService taskService)
        {
            _sharedService = sharedService;
            _planService = planService;
            _taskService = taskService;
        }

        #endregion

        public ActionResult _Navigator()
        {
            ViewBag.PrepageUrl = Prepage.Get();
            _NavigatorModel model = _sharedService.GetNavigator();
            return PartialView(model);
        }

        public PartialViewResult _Pager(_PagerModel model)
        {
            #region format the url

            string path = Request.Url.LocalPath;
            int start = path.LastIndexOf("Page-");
            string pathPrefix = start > -1 ? path.Substring(0, start) : path;

            if (!pathPrefix.EndsWith("/"))
            {
                pathPrefix += "/";
            }

            model.FormatUrl = pathPrefix + "Page-{0}" + Request.Url.Query;

            #endregion

            return PartialView(model);
        }
    }
}